package com.lvmama.common.enums;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/** 
* @ClassName: CommonParentType 
* @Description: TODO
* @author Administrator
*/
public enum CommonParentType {
    
    ALLS("","0","全部"),
    /*VST产品品类*/
    resort_hotel("1","0","度假酒店"),
    cruise("2","0","邮轮"),
    insurance("3","0","保险"),
    visa("4","0","签证"),
    tickets("5","0","门票"),
    attractions_tickets("11","5","景点门票"),
    other_ticket("12","5","其它票 "),
    meal_ticket("13","5","组合套餐票"),
    composite_products("6","0","组合产品"),
    liner_combination_product("8","6","邮轮组合产品"),
    additional_project("7","0","附加项目"),
    shore_tourism("9","7","岸上观光"),
    cruise_add_ons("10","7","邮轮附加项"),
    line("14","0","线路"),
    package_tour("15","14","跟团游"),
    local_tourism("16","14","当地游"),
    hotel_packages("17","14","酒店套餐"),
    traffic_X("29","14","交通+X"),
    custom_tourism("42","14","定制游"),
    free_line("18","14","自由行"),
    wine_scene("181","18","酒+景"),
    machine_wine("182","18","机+酒"),
    transportation_service("183","18","交通+服务"),
    big_traffic("19","0","大交通"),
    air_ticket("20","19","机票"),
    other_air_ticket("21","19","其它机票"),
    train_ticket("22","19","火车票"),
    other_train_tickets("23","19","其它火车票"),
    bus("24","19","巴士"),
    other_bus("25","19","其它巴士"),
    steamer_ticket("26","19","船票"),
    other_steamer_ticket("27","19","其它船票"),
    WIFI_card("28","0","WIFI/电话卡"),
    local_play("30","0","当地玩乐"),
    concert_tickets("31","30","演出票"),
    transport_interchange("41","30","交通接驳"),
    other("90","0","其它"),
    adviser("88","0","意见反馈"),
    presell("99","0","预售");
    
    
    private String value;
    private String parentId;
    private String showName;
    private CommonParentType(String value, String parentId, String showName) {
        this.value = value;
        this.parentId = parentId;
        this.showName = showName;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getParentId() {
        return parentId;
    }
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
    public String getShowName() {
        return showName;
    }
    public void setShowName(String showName) {
        this.showName = showName;
    }
    
    /**
     * VST产品品类
     * @return
     */
    public static CommonParentType[] getVSTProduct(){
        CommonParentType[] statusTypeArr = new CommonParentType[5];
        /*statusTypeArr[0] = CommonParentType.ALLS;*/
        statusTypeArr[0] = CommonParentType.resort_hotel;
        statusTypeArr[1] = CommonParentType.package_tour;
        statusTypeArr[2] = CommonParentType.local_tourism;
        statusTypeArr[3] = CommonParentType.hotel_packages;
        statusTypeArr[4] = CommonParentType.tickets;
        return statusTypeArr;
    }


    /**
     * Description:推荐品类筛选
     * Date:2017/2/25 11:50
     * Created by wxxuyuan
     */
    public static CommonParentType[] getRecommendCategorys() {
        CommonParentType[] statusTypeArr = new CommonParentType[9];
        statusTypeArr[0] = CommonParentType.ALLS;
        statusTypeArr[1] = CommonParentType.tickets;
        statusTypeArr[2] = CommonParentType.package_tour;
        statusTypeArr[3] = CommonParentType.machine_wine;
        statusTypeArr[4] = CommonParentType.transportation_service;
        statusTypeArr[5] = CommonParentType.wine_scene;
        statusTypeArr[6] = CommonParentType.resort_hotel;
        statusTypeArr[7] = CommonParentType.local_tourism;
        statusTypeArr[8] = CommonParentType.liner_combination_product;
        return statusTypeArr;
    }
    
    /**
     * H5页面监控产品品类
     * @return
     */
    public static CommonParentType[] getH5PageMonitorProduct(){
        CommonParentType[] statusTypeArr = new CommonParentType[4];
        statusTypeArr[0] = CommonParentType.ALLS;
        statusTypeArr[1] = CommonParentType.resort_hotel;
        statusTypeArr[2] = CommonParentType.air_ticket;
        statusTypeArr[3] = CommonParentType.train_ticket;
        return statusTypeArr;
    }

    /**
     * 根据value获得H5页面监控产品品类名称
     * @param value
     * @return
     */
    public static String getH5PageMonitorProductShowName(String value){
        String showName="";
        if(value != null && !"".equals(value)){
            CommonParentType[] vSTProductsTypes = CommonParentType.getH5PageMonitorProduct();
            for(CommonParentType vSTProductTypes : vSTProductsTypes){
                if(vSTProductTypes.getValue().equals(value)){
                    showName=vSTProductTypes.getShowName();
                    break;
                }
            } 
        }
        return showName;
    }
    
    /**根据品类的value的值得到其名称
     * @param value
     * @return
     */
    public static String getVSTProductShowName(String value){
        String showName="";
        if(value != null){
            CommonParentType[] vSTProductsTypes = CommonParentType.getVSTProduct();
            for(CommonParentType vSTProductTypes : vSTProductsTypes){
                if(vSTProductTypes.getValue().equals(value)){
                    showName=vSTProductTypes.getShowName();
                    break;
                }
            } 
        }
        return showName;
    }
    
    /**根据parentId获得子级品类的value的集合
     * @param parentId
     * @return
     */
    public static List<String> getValueListByParentId(String parentId){
        List<String> list = new ArrayList<String>();
        if(parentId == null){
            return null;
        }
        CommonParentType[] vSTProductsTypes = CommonParentType.values();
        List<CommonParentType> vSTProductlist = Arrays.asList(vSTProductsTypes);
        for(CommonParentType vSTProductType : vSTProductlist){
            if(vSTProductType.getParentId().equals(parentId)){
                list.add(vSTProductType.getValue());
            }
        }
        return list;
    }
    
    
    /**
     * 根据品类的value获得其父级的value
     * @param value
     * @return
     */
    public static String getParentIdByValue(String value){
        String parentId ="";
        CommonParentType[] vSTProductsTypes = CommonParentType.values();
        List<CommonParentType> vSTProductlist = Arrays.asList(vSTProductsTypes);
        for(CommonParentType vSTProductType : vSTProductlist){
            if(vSTProductType.getValue().equals(value)){
                parentId = vSTProductType.getParentId();
                break;
            }
        }
        return parentId;
    }
    
    /**
     * 根据品类的value获得其名称
     * @param value
     * @return
     */
    public static String getVSTShowName(String value){
        String parentVSTValue = CommonParentType.getParentIdByValue(value);//获得父类品类的value
        String parentVSTShowName = CommonParentType.getVSTProductShowName(parentVSTValue);//获得其品类的名称
        String showName = parentVSTShowName.isEmpty() ? CommonParentType.getVSTProductShowName(value) : parentVSTShowName;
        return showName;
    }
    
    /**
     * 根据品类的名称获得其value
     * @param showName
     * @return
     */
    public static String getValueByShowName(String showName){
        String value="";
        if(showName != null){
            CommonParentType[] vSTProductsTypes = CommonParentType.getVSTProduct();
            for(CommonParentType vSTProductTypes : vSTProductsTypes){
                if(vSTProductTypes.getShowName().equals(showName)){
                    value=vSTProductTypes.getValue();
                    break;
                }
            } 
        }
        return value;
    }
    
    
    /** 
    * @Title: geAllCategory 
    * @Description: 流量二期所有品类
    * @param @return    设定文件 
    * @return CommonParentType[]    返回类型 
    * @throws 
    */
    public static CommonParentType[] geAllCategory(){
        CommonParentType[] statusTypeArr = new CommonParentType[17];
        statusTypeArr[0] = CommonParentType.resort_hotel;
        statusTypeArr[1] = CommonParentType.liner_combination_product;
        statusTypeArr[2] = CommonParentType.visa;
        statusTypeArr[3] = CommonParentType.attractions_tickets;
        statusTypeArr[4] = CommonParentType.other_ticket;
        statusTypeArr[5] = CommonParentType.meal_ticket;
        statusTypeArr[6] = CommonParentType.package_tour;
        statusTypeArr[7] = CommonParentType.local_tourism;
        statusTypeArr[8] = CommonParentType.hotel_packages;
        statusTypeArr[9] = CommonParentType.wine_scene;
        statusTypeArr[10] = CommonParentType.machine_wine;
        statusTypeArr[11] = CommonParentType.transportation_service;
    	statusTypeArr[12] = CommonParentType.WIFI_card;
    	statusTypeArr[13] = CommonParentType.concert_tickets;
    	statusTypeArr[14] = CommonParentType.transport_interchange;
    	statusTypeArr[15] = CommonParentType.adviser;
        statusTypeArr[16] = CommonParentType.line;
        return statusTypeArr;
    }


    /** 
    * @Title: getCategoryShowName 
    * @Description: TODO(这里用一句话描述这个方法的作用) 
    * @param @param value
    * @param @return    设定文件 
    * @return String    返回类型 
    * @throws 
    */
    public static String getCategoryShowName(String value){
        String showName="";
        if(value != null){
            CommonParentType[] vSTProductsTypes = CommonParentType.geAllCategory();
            for(CommonParentType vSTProductTypes : vSTProductsTypes){
                if(vSTProductTypes.getValue().equals(value)){
                    showName=vSTProductTypes.getShowName();
                    break;
                }
            }
        }
        return showName;
    }
    
 /** 
* @Title: getCategoryValueByShowName 
* @Description:流量二期根据品类name得到id 
* @param @param showName
* @param @return    设定文件 
* @return String    返回类型 
* @throws 
*/
public static String getCategoryValueByShowName(String showName){
        String value="";
        if(showName != null){
            CommonParentType[] vSTProductsTypes = CommonParentType.geAllCategory();
            for(CommonParentType vSTProductTypes : vSTProductsTypes){
                if(vSTProductTypes.getShowName().equals(showName)){
                    value=vSTProductTypes.getValue();
                    break;
                }
            } 
        }
        return value;
    }
}
